
@include('Home.head')
<body>
<div class="container" id="app">
    @include('Home.member.header')
    <div class="my-nav-bar">
    	<ol class="am-breadcrumb">
          <li><a href="#">首页</a></li>
          <li><a href="#">会员</a></li>
        </ol>
    </div>
	<div class="cart-panel">
        <h3>门店会员</h3>
        <div class="withdrawals-panel">
        	<table class="am-table am-table-striped am-table-hover comm-table">
            	<thead>
                    <tr>
                        <th>名称</th>
                        <th>电话</th>
                        <th>日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                	<tr v-for="val in deposit">
                        <td>@{{ val.money }}</td>
                        <td>@{{ val.nickname }}</td>
                        <td>@{{ val.remark }}</td>
                        <td>@{{ val.time }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <!--底部-->
    @include('Home.foot')
</div>
</body>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            title: '我的会员',
            user:{
                type:1,
                phone:'',
                money:'',
                password:'',
            },
            deposit:[],
            status:0,
            user_name:''
        },
        methods: {
            //初始化 系统管理员列表
            initialize: function () {
                $.post("/home/member/deposit", {'_token': '{{csrf_token()}}',class:'select'}, function (res) {
                    if (res.code) {
                        app.deposit = res.data;
                    } else {
                        layer.msg(res.data);
                    }
                });
            },
            upperCase:function () {
                if(!(/^[1][3,4,5,7,8,9][0-9]{9}$/.test(app.user.phone))){
                    layer.msg('请输入正确的电话号码');
                    return false;
                }
                $.post("/home/member/deposit", {'_token': '{{csrf_token()}}',class:'estimate',user:app.user}, function (res) {
                    if (res.code) {
                        app.user_name = res.data.user_name
                    } else {
                        layer.msg(res.data);
                    }
                });
            },
            add:function () {
                var rico = this
                if(!(/^[1][3,4,5,7,8,9][0-9]{9}$/.test(app.user.phone))){
                    layer.msg('请输入正确的电话号码');
                    return false;
                }
                if(!(/^\+?[1-9][0-9]*$/.test((app.user.money / 100)))){
                    layer.msg('请输入100的倍数');
                    return false;
                }
                if(app.user.password == ''){
                    layer.msg('请输入密码');
                    return false;
                }
                layer.confirm('确定打款给'+app.user_name+'吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    app.status = 1;
                    layer.msg('加载中', {
                        icon: 16
                        ,time:50000
                        ,shade: 0.01
                    });
                    $.post("/home/member/deposit", {'_token': '{{csrf_token()}}',class:'add',user:app.user}, function (res) {
                        layer.closeAll('loading');
                        if (res.code) {
                            app.status = 0;
                            layer.msg(res.data);
                            app.user = [];
                            rico.initialize();
                        } else {
                            app.status = 0;
                            layer.msg(res.data);
                        }
                    });
                })

            },
        },
        //自动执行
        mounted: function () {
            this.initialize();
        },
    })
</script>
</html>
